package com.jy.adscm.operation.base.service.impl;

import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.operation.base.bean.JyGoods;
import com.jy.adscm.operation.base.mapper.mysql.JyGoodsMapper;
import com.jy.adscm.operation.base.service.JyGoodsService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import com.jy.adscm.utils.AdscmBaseUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-29
 */
@Service
public class JyGoodsServiceImpl extends ServiceImpl<JyGoodsMapper, JyGoods> implements JyGoodsService {
 @Autowired
    JyUserMapper jyUserMapper;
    @Override
    public List<JyGoods> selectAll() {
        List<JyGoods> jyGoods = super.selectList(null);
        for (JyGoods jyGood : jyGoods)
            if (AdscmBaseUtils.getInstance().isNotEmpty(jyGood.getCreateperson(), null)) {
                JyUser jyUser = jyUserMapper.selectById(jyGood.getCreateperson());
                if (!AdscmBaseUtils.getInstance().isNotEmpty(jyUser, null)) {
                    jyGood.setCreatepersonName(jyGood.getCreateperson());
                }else{
                    jyGood.setCreatepersonName(jyUser.getName());
                }

            }
        return jyGoods;
    }
}
